//package com.fundodoo.sfe.admin.controller;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.apache.shiro.authz.annotation.RequiresPermissions;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import com.fundodoo.sfe.common.annotation.Log;
//import com.fundodoo.sfe.common.controller.BaseController;
//import com.fundodoo.sfe.domain.MailSettings;
//import com.tpv.vc.common.domain.ResponseBo;
//import com.tpv.vc.system.dao.MailSettingMapper;
//import com.tpv.vc.system.service.impl.SmtpServiceImpl;
//
//
///**
// * SMTP Settings
// * @author ken.he
// * @date 2019-01-14 15:54:34
// */
//@Controller
//public class SmtpController extends BaseController{
//
//    private Logger log = LoggerFactory.getLogger(this.getClass());
//
//    @Autowired
//    private SmtpServiceImpl smtpServiceImpl;
//    @Autowired
//    private MailSettingMapper mailSettingMapper;
//    
//    @Log("邮件配置")
//    @RequestMapping("smtp")
//    @RequiresPermissions("smtp:setting")
//    public String online() {
//        return "system/smtp/settings";
//    }
//
//    /**
//     *	 显示设置页面
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("smtp/settings")
//    @RequiresPermissions("smtp:setting")
//    public Map<String, Object> settings() {
//    	Map<String, Object> map = new HashMap<String, Object>();
//    	List<MailSettings> settings = smtpServiceImpl.getMailConfigs();
//    	for(MailSettings ms : settings) {
//    		map.put(ms.getName(), ms.getValue());
//    	}
//    	return map;
//    }
//    
//    /**
//     *	saveConfigs
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("smtp/save")
//    public void saveConfigs(String openMailAlert, String fromMailAddress, String fromMailNickname, String adminMailAddress, String smtpHost, 
//    		String smtpPort, String smtpUsername, String smtpPwd, String secretKey) {
//    	
//    	List<MailSettings> listSettings = new ArrayList<MailSettings>();
//    	if("0".equals(openMailAlert)) {
//    		listSettings.add(createMailSettingObject("OPEN_MAIL_ALERT", "Off"));
//    	}else {
//    		listSettings.add(createMailSettingObject("OPEN_MAIL_ALERT", "SMTP"));
//    	}
//    	listSettings.add(createMailSettingObject("FROM_MAIL_ADDRESS", fromMailAddress));
//    	listSettings.add(createMailSettingObject("FROM_MAIL_NICKNAME", fromMailNickname));
//    	listSettings.add(createMailSettingObject("ADMIN_MAIL_ADDRESS", adminMailAddress));
//    	listSettings.add(createMailSettingObject("SMTP_HOST", smtpHost));
//    	listSettings.add(createMailSettingObject("SMTP_PORT", smtpPort));
//    	listSettings.add(createMailSettingObject("SMTP_USERNAME", smtpUsername));
//    	listSettings.add(createMailSettingObject("SMTP_PWD", smtpPwd));
//    	if("5".equals(secretKey)) {
//    		listSettings.add(createMailSettingObject("SMTP_SECRET_KEY", "Off"));
//    	}else if("6".equals(secretKey)){
//    		listSettings.add(createMailSettingObject("SMTP_SECRET_KEY", "SSL"));
//    	}else if("7".equals(secretKey)){
//    		listSettings.add(createMailSettingObject("SMTP_SECRET_KEY", "TLS"));
//    	}else {
//    		listSettings.add(createMailSettingObject("SMTP_SECRET_KEY", "Off"));
//    	}
//    	smtpServiceImpl.saveMailConfigs(listSettings);
//    	
//    }
//    
//    private MailSettings createMailSettingObject(String key, String value) {
//    	MailSettings ms = new MailSettings();
//    	ms.setName(key);
//    	ms.setValue(value);
//    	return ms;
//    }
//    
//	@ResponseBody
//	@RequestMapping("smtp/sendmail")
//	public ResponseBo sendEmail(String meetingId, int type, HttpServletRequest request) {
//		ResponseBo resp = ResponseBo.ok();
//		try {
//			int ret = smtpServiceImpl.sendMeetingEmail(meetingId, type, request);
//			// 0:成功
//			// 1:获取邮件配置信息失败
//			// 2:邮件地址错误
//			// -1:邮件功能已关闭
//			// -2:异常
//			resp.put("code", ret);
//		} catch (Exception e) {
//			resp.put("code", -2);
//			resp.put("msg", e.getMessage());
//		}
//		return resp;
//	}
//}
